<template>
  <div class="wrapper-verify">
    <digit-verify :value="value" v-bind="$attrs" @input="onInputVerify"></digit-verify>
  </div>
</template>

<script>
import DigitVerify from '@/components/DigitVerify.vue'

export default {
  inheritAttrs: false,
  name: 'VerifyWrapper',
  props: {
    value: [String, Number],
    decimal: {
      type: Number,
      default: 2
    }
  },
  components: {
    DigitVerify
  },
  methods: {
    onInputVerify (value) {
      console.log(value)
      const reg = new RegExp(`^(([1-9]{1}\\d*)|([0]{1}))(\\.(\\d){0,${this.decimal}})?$`)
      if (reg.test(value) || value === '') {
        this.$emit('input', value)
      }
    }
  }
}
</script>
